package datatypes;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Stack;

import Misc.Variables;

/**
 * Datatype displaying an exam with all its properties
 * @author Rupert
 *
 */
public class Exam {
	/**
	 * Properties
	 */
	private int id;
	private String subjectName;
	private String subjectIdentification;
	private Date  examDate;
	private Date evaluationBeginDate;
	private Date evaluationEndDate;
	private int numberOfExercises;
	private int numberOfParticipants;
	private double[] maxPointsPerExercise;
	private double[] gradingArray;
	private Stack<Exercise> exercises;
	private String facility;
	private String faculty;
	private String professorship;
	private String examiner;
	private String subjectFirstPossibility;
	private String subjectSecondPossibility;
	private Date newEvaluationBegin;
	private Date newEvaluationEnd;
	
	private String pdfPath;
	
	public Exam(){
	}
	
	
	public Exam(int id, String subjectName, String subjectIdentifcation, Date examDate, Date evaluationBeginDate, Date evaluationEndDate, int numberOfExercises,
					int numberOfParticipants, String facility, String faculty, String professorship, String examiner, String subjectFirstPossibility,  String subjectSecondPossibility, double[] maxPointsPerExercise, double[] gradingArray, Stack<Exercise> exercises){
		this.id = id;
		this.subjectName = subjectName;
		this.subjectIdentification = subjectIdentifcation;
		this.examDate = examDate;
		this.evaluationBeginDate = evaluationBeginDate;
		this.evaluationEndDate = evaluationEndDate;
		this.numberOfParticipants = numberOfParticipants;
		this.maxPointsPerExercise = maxPointsPerExercise;
		this.gradingArray = gradingArray;
		this.facility = facility;
		this.faculty = faculty;
		this.professorship = professorship;
		this.setExaminer(examiner);
		this.setSubjectFirstPossibility(subjectFirstPossibility);
		this.setSubjectSecondPossibility(subjectSecondPossibility);
		this.setExercises(exercises);
		
	}
	
	
	/**
	 * Getter & Setter
	 */
	
	public String getSubjectName() {
		return subjectName;
	}
	public void setSubjectName(String subjectName) {
		this.subjectName = subjectName;
	}
	public String getSubjectIdentification() {
		return subjectIdentification;
	}
	public void setSubjectIdentification(String subjectIdentification) {
		this.subjectIdentification = subjectIdentification;
	}
	public Date getExamDate() {
		return examDate;
	}
	public void setExamDate(Date examDate) {
		this.examDate = examDate;
	}
	public int getNumberOfExercises() {
		return numberOfExercises;
	}
	public void setNumberOfExercises(int numberOfExercises) {
		this.numberOfExercises = numberOfExercises;
	}
	public double[] getMaxPointsPerExercise() {
		return maxPointsPerExercise;
	}
	public void setMaxPointsPerExercise(double[] maxPointsPerExercise) {
		this.maxPointsPerExercise = maxPointsPerExercise;
	}
	public int getNumberOfParticipants() {
		return numberOfParticipants;
	}
	public void setNumberOfParticipants(int numberOfParticipants) {
		this.numberOfParticipants = numberOfParticipants;
	}
	/**
	 * @return the facility
	 */
	public String getFacility() {
		return facility;
	}


	/**
	 * @param facility the facility to set
	 */
	public void setFacility(String facility) {
		this.facility = facility;
	}


	/**
	 * @return the faculty
	 */
	public String getFaculty() {
		return faculty;
	}


	/**
	 * @param faculty the faculty to set
	 */
	public void setFaculty(String faculty) {
		this.faculty = faculty;
	}


	/**
	 * @return the professorship
	 */
	public String getProfessorship() {
		return professorship;
	}


	/**
	 * @param professorship the professorship to set
	 */
	public void setProfessorship(String professorship) {
		this.professorship = professorship;
	}


	/**
	 * @return the examiner
	 */
	public String getExaminer() {
		return examiner;
	}


	/**
	 * @param examiner the examiner to set
	 */
	public void setExaminer(String examiner) {
		this.examiner = examiner;
	}


	/**
	 * @return the subjectFirstPossibility
	 */
	public String getSubjectFirstPossibility() {
		return subjectFirstPossibility;
	}


	/**
	 * @param subjectFirstPossibility the subjectFirstPossibility to set
	 */
	public void setSubjectFirstPossibility(String subjectFirstPossibility) {
		this.subjectFirstPossibility = subjectFirstPossibility;
	}


	/**
	 * @return the subjectSecondPossibility
	 */
	public String getSubjectSecondPossibility() {
		return subjectSecondPossibility;
	}


	/**
	 * @param subjectSecondPossibility the subjectSecondPossibility to set
	 */
	public void setSubjectSecondPossibility(String subjectSecondPossibility) {
		this.subjectSecondPossibility = subjectSecondPossibility;
	}


	public double[] getGradingArray() {
		return gradingArray;
	}
	public void setGradingArray(double[] gradingArray) {
		this.gradingArray = gradingArray;
	}
	public Date getEvaluationBeginDate() {
		return evaluationBeginDate;
	}
	public void setEvaluationBeginDate(Date evaluationBeginDate) {
		this.evaluationBeginDate = evaluationBeginDate;
	}
	public Date getEvaluationEndDate() {
		return evaluationEndDate;
	}
	public void setEvaluationEndDate(Date evaluationEndDate) {
		this.evaluationEndDate = evaluationEndDate;
	}


	public int getId() {
		return id;
	}
	public void setId(int id){
		this.id = id;
	}


	/**
	 * @return the exercises
	 */
	public Stack<Exercise> getExercises() {
		return exercises;
	}


	/**
	 * @param exercises the exercises to set
	 */
	public void setExercises(Stack<Exercise> exercises) {
		this.exercises = exercises;
	}
	
	/**
	 * get PDF Path. This methods returns a String that contains the PATH to the exam.
	 * @return
	 */
	public String getPdfPath(){
		
		String pdfFilePath = Variables.RELATIVE_PDF_SAVINGSPACE_EXAM;
		

		SimpleDateFormat simpleDF = new SimpleDateFormat();
		simpleDF.applyPattern("yyyy-MM-dd");
		
		String pdfileName = this.getSubjectIdentification() +"_"+ simpleDF.format(this.getExamDate())+".pdf";
		
		
		pdfFilePath = pdfFilePath +"examId"+this.getId()+"/"+pdfileName;
		return pdfFilePath;
	}


	/**
	 * @return the newEvaluationBegin
	 */
	public Date getNewEvaluationBegin() {
		return newEvaluationBegin;
	}


	/**
	 * @param newEvaluationBegin the newEvaluationBegin to set
	 */
	public void setNewEvaluationBegin(Date newEvaluationBegin) {
		this.newEvaluationBegin = newEvaluationBegin;
	}


	/**
	 * @return the newEvaluationEnd
	 */
	public Date getNewEvaluationEnd() {
		return newEvaluationEnd;
	}


	/**
	 * @param newEvaluationEnd the newEvaluationEnd to set
	 */
	public void setNewEvaluationEnd(Date newEvaluationEnd) {
		this.newEvaluationEnd = newEvaluationEnd;
	}
	
}
